package com.cuotoniu.lazybug.core.config.web;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

import com.cuotoniu.lazybug.common.util.Path;

/**
 * Model and View Config
 * match the dir with classpath:/WEB-INF/jsp/
 * and match the suffix '.jsp'
 * 
 * @author HLJ
 *
 */
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.cuotoniu.lazybug")
public class LazyBugConfig {

	/**
	 * Create the View Resolver
	 * 
	 * @return
	 */
	 @Bean public InternalResourceViewResolver configureInternalResourceViewResolver() {
		  InternalResourceViewResolver resolver = new InternalResourceViewResolver();
		  resolver.setPrefix("/WEB-INF/jsp/");		/** Set the prefix(/WEB-INF/jsp) of the pages */
		  resolver.setSuffix(".jsp");				/** Set the suffix(jsp) of pages */
		  resolver.setViewClass(JstlView.class);	/** Use the JSTL View Class */
		  return resolver;
	 }
	 
	 /**
	  * Create the Path Object  
	  * 
	  * @return
	  */
	 @Bean public Path path(){
		 return new Path();
	 }
	 
}
